/**
 * 
 */
package com.nxn.core.model;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@NamedQueries({
	@NamedQuery(
		name = "findMenuResourceByRoles",
		query = "from RoleAuth ra where ra.role.id in (:roles) and ra.resource.type = 1 and ra.action.name = 'query'"
	)
})
@Entity
@Table(name="t_role_auth")
public class RoleAuth extends IdEntity {
	
	private Role role;
	private Resources resource;
	private Actions action;
	
	@ManyToOne(cascade={CascadeType.MERGE})
    @JoinColumn(name="role_id")
	public Role getRole() {
		return role;
	}
	@ManyToOne(cascade={CascadeType.MERGE})
    @JoinColumn(name="resource_id")
	public Resources getResource() {
		return resource;
	}
	@ManyToOne(cascade={CascadeType.MERGE})
    @JoinColumn(name="action_id")
	public Actions getAction() {
		return action;
	}
	
	public void setRole(Role role) {
		this.role = role;
	}
	public void setResource(Resources resource) {
		this.resource = resource;
	}
	public void setAction(Actions action) {
		this.action = action;
	}
}